package com.example.web.controller.tag;

public class PageModel {

	private int pageSize;//每页大小
	private int cpage;
	private int totalCount;
	private int totalPage;
	private int nextPage;
	private int prePage;
	private int pageFirst;
	private int dispPageCount = 10;
	public int getPageSize() {	
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		if(pageSize==0){
			pageSize=10;
		}
		this.pageSize = pageSize;
	}
	public int getCpage() {
		if(cpage==0){
			cpage=1;
		}
		return cpage;
	}
	public void setCpage(int cpage) {
		if(cpage==0){
			cpage=1;
		}
		this.cpage = cpage;
	}
	public int getTotalCount() {
		return totalCount;
	}
	public void setTotalCount(int totalCount) {
		this.totalCount = totalCount;
	}
	public int getTotalPage() {
		 int pageCount = 0;
         if (getPageSize() > 0 && getTotalCount() > 0)
         {
             pageCount = totalCount / pageSize;
             int count = totalCount % pageSize;
             if (count > 0)
             {
                 pageCount = pageCount + 1;
             }
         }
         totalPage= pageCount;
		return totalPage;
	}
	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}
	public int getNextPage() {
		 if((cpage+1)>getTotalPage())
         {
			 nextPage= totalPage;
         }
         else
         {
        	 nextPage= cpage + 1;
         }
		return nextPage;
	}
	public void setNextPage(int nextPage) {
		this.nextPage = nextPage;
	}
	public int getPrePage() {
		if ((cpage - 1) < 1)
        {
			prePage= 1;
        }
        else
        {
            return cpage - 1;
        }
		return prePage;
	}
	public void setPrePage(int prePage) {
		this.prePage = prePage;
	}
	public int getPageFirst() {
		 int result = 1;
         //当前页大于要显示的页。起始页肯定不是第一页
         if (cpage > dispPageCount)
         {
             int num = (cpage % dispPageCount);
             if (num > 0)
             {
                 result = ((cpage / dispPageCount) * dispPageCount) + 1;
             }
             else
             {
                 result = (((cpage / dispPageCount) - 1) * dispPageCount) + 1;
             }
         }
         pageFirst= result;
		return pageFirst;
	}
	public void setPageFirst(int pageFirst) {
		this.pageFirst = pageFirst;
	}
	public int getDispPageCount() {
		return dispPageCount;
	}
	public void setDispPageCount(int dispPageCount) {
		if(dispPageCount==0){
			dispPageCount=10;
		}
		this.dispPageCount = dispPageCount;
	}
	
	
	
}
